<template>
    <div class="newsinfo-container">
        <h1 class="title">{{ newsinfo.title }}</h1>
        <h3 class="subtitle">
            <span>发表时间: {{ newsinfo.addTime | dateFormat }}</span>
            <span>点击:{{ newsinfo.click }}次</span>
        </h3>
        <hr>
        <div id="content" v-html="newsinfo.content">

        </div>
        <comment-box></comment-box>
    </div>
</template>
<script>
import { Toast } from 'mint-ui';
import comment from '../subcomponents/comment.vue'
export default {
    data() {
        return {
            id: this.$route.params.id,
            newsinfo: []
        }
    },
    created() {
        this.getnewsinfo()
    },
    methods: {
        getnewsinfo() {
            this.$http.get("news/getNewsInfo?id=" + this.id).then( result => {
                if(result.body.state === '0'){
                    this.newsinfo = result.body.data;
                }else {
                    Toast("获取新闻列表失败")
                }
            })
        }
    },
    components: {
        "comment-box": comment
    }
}
</script>

<style lang="scss">
    .newsinfo-container{
        .title {
            font-size: 16px;
            text-align: center;
            color: gold;
            // margin: 15px 0px;
        }
        .subtitle {
            font-size: 13px;
            color: skyblue;
            display: flex;
            justify-content: space-between;
        }
    }
</style>